﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AutoMapper;

using Happy.Archetype;
using Happy.Application.Domain;
using Happy.Cms.Domain;
using Happy.Cms.Domain.Contacts;
using Happy.Cms.Query.Contacts;

namespace Happy.Cms.Application.Contacts
{
    [ApplicationService]
    public sealed class ContactService : AggregateRootService<Contact, ContactView, ICmsUnitOfWork>
    {
        protected override Contact CreateAggregate(ContactView viewModel)
        {
            var aggregate = new Contact(Guid.NewGuid());

            return Mapper.Map(viewModel, aggregate);
        }

        protected override void UpdateAggregate(Contact aggregate, ContactView viewModel)
        {
            Mapper.Map(viewModel, aggregate);
        }
    }
}
